#include <cassert>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <ctime>
#include <iostream>
#include "Divider.h"
#include "types.h"
#include <random>

int main() {
    std::mt19937 gen(time(NULL));
    std::uniform_int_distribution<SInt> randint_x(-10000, -1);
    std::uniform_int_distribution<SInt> randint_y(-10000,-1);
    std::uniform_int_distribution<UInt> randint_100(1, 100);
    Divider m;
    m.reset();

    int N = 100000;

    int correct_count = 0;
// std::printf("q=%d, r=%d\n", 10/(-3), 10%(-3));
    for (int i = 0; i < N; ++i) {
        SInt y = randint_y(gen);
        SInt x = y * randint_100(gen) + randint_x(gen);
        if (y == 0) {
            y = 1;
        }
        // UInt x = 10;
        // UInt y = -3;
        auto [result, answer] = m.SS(x, y);
        if (result.quotient == answer.quotient && result.remainder == answer.remainder) {
            correct_count++;
        } else {
            std::printf("x: %d, y: %d\n", x, y);
            std::printf("result: %d, %d\n", result.quotient, result.remainder);
            std::printf("answer: %d, %d\n", answer.quotient, answer.remainder);
            std::printf("Wrong Answer!\n");
            return 1;
        }
    }
    
    std::printf("Correct Rate: %d/%d\n", correct_count, N);
    return 0;
}
